{include file=header.html}
 <script type="text/javascript" language="javascript" src="{lib file=jquery-1.6.3.min.js}"></script>
<script language="javascript" type="text/javascript" src="{lib file=jquery.ui/jquery.ui.js}"></script>
<script language="javascript" type="text/javascript" src="{res file=DatePicker/WdatePicker.js}"></script>
<script language="javascript" type="text/javascript" src="{res file=js/fabric_info.js}"></script>
<script language="javascript" type="text/javascript" src="{res file=js/jquery.funkyUI.js}"></script>
<script language="javascript" type="text/javascript" src="{res file=js/common.js}"></script>
<script language="javascript" type="text/javascript" src="{lib file=jquery.plugins/jquery.validate_1.11.0.js}"></script>
<script language="javascript" type="text/javascript" src="{res file=js/select.js}"></script>
<style type="text/css">
.btn-2{margin-bottom:5px;}
.table_no_border,.table_no_border td,.table_no_border th{
	padding:0;
	margin:0;
	border-bottom:none;
	border-top:none;
	}
.fabric_info_list td input,.fabric_info_list td select{width:93%;}
.fabric_info_table td{
	border-left:none;
	border-bottom:none;
	padding:2px;
	}
.fabric_info_table th
{
   border-top:none;
}
.no_left_border
{
	border-left:none;
}
.no_right_border
{
	border-right:none;
}
.img_border{
	border: 2px solid #000000;width: 80px;height: 60px;
}
</style>
<script type="text/javascript">
$(function() {
	 $('#sample_form').validate({
        onkeyup : false,
		onfocusout : false,
        rules : {
			arrival_date: {
				required: true,
				dateISO: true
			},
			brand_id: {
				min: 1
			},
			buyer_id: {
				required: true,
				min: 1
			},
			merchandiser_id: {
				min: 1
			},
			sample_sn: {
				required: true
			},
			ref_sample_style:{
				min: 1
			}
        },
        messages : {
			arrival_date: {
				required: '{$lang.arrival_date_not_empty}',
				dateISO: '{$lang.date_format_error}'
			},
			brand_id: {
				min: '{$lang.brand_select_pls}'
			},
			buyer_id: {
				required: '{$lang.buyer_select_pls}',
				min: '{$lang.buyer_select_pls}'
			},
			merchandiser_id: {
				min: '{$lang.merch_select_pls}'
			},
			sample_sn: {
				required: '{$lang.sample_sn_not_empty}'
			},
			ref_sample_style: {
				min: '{$lang.ref_sample_style_select_pls}'
			}
        }
    });
	
	$('select[select_input="select_input"]').each(function(i) {
		init_select_input($(this));
	});
	$('div.select-input').each(function(i) {
		$(this).css('z-index', $('div.select-input').length - i);
	});
	$('#add_fabric_info').click(function() {
		var tr = $('<tr><th align="right">{$lang.desc}：</th><td class="tab-align-l" colspan="3"></td><th align="right">{$lang.fabric_shop_name}：</th><td class="tab-align-l" colspan="3"></td><td colspan="2" align="left"></td></tr>');
		var sel_input = $($('#fabric_shop_data').html());
		sel_input.attr('select_input', 'select_input');
		sel_input.attr('name', 'new_fabric_info[][fabric_shop_id]');
		sel_input.attr('id', 'new_fabric_info[][fabric_shop_id]');
		sel_input.attr('class', 'input-3');
		var desc = $('<input type="text" class="input-3" name="new_fabric_info[][description]">');
		tr.find('td:eq(0)').append(desc);
		tr.find('td:eq(1)').append(init_select_input(sel_input));
		$('div.select-input').each(function(i) {
			$(this).css('z-index', $('div.select-input').length - i);
		});
		tr.css('background-color', '#F4F8FA');
		var add_fabric_shop = $('#add_fabric_shop');
		tr.insertAfter(add_fabric_shop.parents('tr'));
		if ($('input.btn-2[value="移除"]').length < 1) {
			add_fabric_shop.parent().append($('<input type="button" value="移除" class="btn-2" />'));
		}
		tr.find('td:eq(2)').append($('<input type="button" value="移除" class="btn-2" />'));
		tr.find('td:eq(2)').append(add_fabric_shop);
	//	$('input.btn-2[value="移除"]').click(function() {
	//		remove_fabric_shop($(this));
	//	});
		sort_new_fabric_info();
	});

	$('#add_fabric_shop').click(function() {
		var value = $.trim(prompt("请输入布行/档口名称：", ''));
		if (value != '' && confirm('系统将增加此布行信息到系统，请确认是否重复。\r\n' + value + '\r\n确定要添加该布行吗？')) {
			$.post('index.php?app=fabric_shop&act=AjaxAdd', {'fabric_shop_name' : value}, function(json) {
				if (json.done) {
					ref_fabric_shop();
				}
				alert(json.msg);
			}, 'json');
		}
	});
	$('input[acttype="confirm"]').click(function() {
		if (confirm('是否已经保存信息？更新样板信息之后将会使已确认样板状态无效。\r\n\r\n是否继续？')) {
			$.getJSON('index.php?app=sample&act=confirm&id={$smarty.get.id}', function(json) {
				alert(json.msg);
			});
		}
	});
	
});

function sort_new_fabric_info()
{
	$('input[name^="new_fabric_info"][name$="[description]"]').each(function(i) {
		$(this).attr('name', 'new_fabric_info[' + i + '][description]');
	});
	$('input[name^="new_fabric_info"][name$="[fabric_shop_id]"]').each(function(i) {
		$(this).attr('name', 'new_fabric_info[' + i + '][fabric_shop_id]');
		$(this).attr('id', 'new_fabric_info[' + i + '][fabric_shop_id]');
	});
}

function remove_fabric_shop(_this)
{
	if (!confirm('确定要移除该面料信息吗？')) {
		return;
	}
	$(_this).parent().parent().remove();
}

function addbuff()
{

	var buff=encodeURI($("#add_buff").val());
	if(buff!="")
	{
		var url="{$site_url}/index.php?app=sample&act=addrecord&id={$sample.sample_id}&buff="+buff;
		$.getJSON(url,function(ret){
				if(ret.done)
				{
					$("#add_buff").val("");
					if($("#record_list p").size()>0)
					{
					$("#record_list p:first").before(ret.retval);
					}
					else
					{
					$("#record_list").append(ret.retval);
					}
				}
				else
				{
					alert(ret.msg);
				}
			
			});	
	}
}

function check_factory_submit(){

	if(confirm('请仔细检查填写内容是否正确，确认是否提交？')==true){
		if($("[name='factory_price']").val()=="")
		{
			alert("请输入工厂报价");
			return false;
		}
		
		if($("#factory_files a").size()==0)
		{
			alert("请上传报价单");
			return false;
		}
		var ml_num=0;
		$(".fabric_info_list").each(function(){
				
			if($(this).find("[item='fabric_shop_name']").val()!=0 && $(this).find("[item='item']").val()!=0)
			{
				ml_num++;
			}
		});
		
		if(ml_num==0)
		{
			alert("请输入面料信息");
			return false;
		}
		
		
	}
	
	return true;
}

function check_desc()
{
	
	if($("#approve_no_desc").val()=="")
	{
		$.funkyUI({url:"index.php?app=sample&act=approve_not_pass",css:{width:"455",height:"330"}});
		return false;
	}
	return true;
}

function re_factory()
{
	
	if($("#return_factory_desc").val()=="")
	{
		
		$.funkyUI({url:"index.php?app=sample&act=return_factory",css:{width:"455",height:"330"}});
		return false;
	}
	return true;
}

//面料需求
function assign_merch_fabric(){
	var url="index.php?app=merchant&act=merch_fabric&sample_id={$sample.sample_id}";
	location.href=url;
}
</script>
<body>
<div id="fabric_shop_data" style="display:none;"><select><!--{foreach from=$fabricshop_list item=fabric_shop}--><option value="{$fabric_shop.fabric_shop_id}">{$fabric_shop.fabric_shop_name|escape}</option><!--{/foreach}--></select></div>
<div class="sub-body">
      
  <div class="tab-frame" style="width:900px;">
  <h3 class="tab-title-1"><span>{$lang.sample_more_info}</span></h3>
		<form method="post" id="sample_form" action="{url app=sample&act=$smarty.get.act&id=$smarty.get.id}">
    <table cellspacing="0" width="100%" cellpadding="0" class="tab-display">
    <tr>
      <th style="width:100px;" align="right">{$lang.status}：</th>
      <td class="tab-align-l">{$lang.statuies.$sample.status}</td>
      <th colspan="4">{$lang.front_pic}</th>
		<th colspan="4">{$lang.other_pic}</th>
      </tr>
      <tr>
        <th align="right">{$lang.arrival_date}：</th>
        <td class="tab-align-l">
        {$sample.arrival_date|date:Y-m-d}
          </td>
          <td colspan="4" rowspan="11"><img src="{$sample.front_pic}" id="front_pic_show" width="220" height="264" /><input type="hidden" name="front_pic" id="front_pic" value="" onChange="document.getElementById('front_pic_show').src=this.value;" />
        <input type="hidden" name="front_pic_small" id="front_pic_small" value="" /></td>
		<td colspan="4" rowspan="11"><img src="{$sample.other_pic}" id="other_pic_show" width="220" height="264" /><input type="hidden" name="other_pic" id="other_pic" value="" onChange="document.getElementById('other_pic_show').src=this.value;" /></td>
      </tr>
      <tr>
        <th align="right">{$lang.sample_sn}：</th>
        <td class="tab-align-l">

        {$sample.sample_sn}
          </td>
      </tr>
      <tr>
        <th align="right">{$lang.ref_sample_style}：</th>
        <td class="tab-align-l">
        <!--{foreach from=$lang.ref_sample_styles item=item key=k}-->
            {if $k eq $sample.ref_sample_style}{$item}{/if}
            <!--{/foreach}-->
          </td>
      </tr>
      <tr>
        <th align="right">{$lang.brand_name}：</th>
        <td class="tab-align-l">
        {$sample.brand_name}({$sample.company_info.company_name|escape})
          </td>
      </tr>

      <tr>
        <th align="right">{$lang.buyer_name}：</th>
        <td class="tab-align-l">
           {$sample.buyer_name}
          </td>
      </tr>
   
      <tr>
        <th align="right">{$lang.merchandiser}：</th>
        <td class="tab-align-l">        
            {$sample.user_name}

          </td>
      </tr>
      <tr>
        <th align="right">{$lang.style_name}：</th>
        <td class="tab-align-l">
        	<!--{foreach from=$style_list item=style1}-->
            {if $sample.style_id == $style1.style_id}{$style1.style_name|escape}{/if}
			<!--{/foreach}-->

         </td>
      </tr>
      <tr>
       <th align="right">{$lang.factory_name}：</th>
        <td class="tab-align-l">
        {$sample.factory_name|escape}

        </td>
      </tr>
      <tr>
          <th align="right">{$lang.to_factory_date}：</th>
        <td class="tab-align-l">
        {$sample.to_factory_date|date:Y-m-d}
        </td>
      </tr>
      
      <tr>
          <th align="right">{$lang.send_sample_date}：</th>
        <td class="tab-align-l">
		{$sample.send_sample_date|date:Y-m-d}
       </td>
      </tr>
     
      <tr>
        <th align="right">{$lang.order_sn}：</th>
        <td class="tab-align-l">
{$sample.order_sn|escape}
        </td>
      </tr>
      <!-- {if $user.role==USER_MERCHANDISER || $user.role==USER_MANAGER || $user.role==USER_FINANCE || $user.role==USER_MERCHANDISER_ADMIN || $user.role==USER_CIVILIAN} -->
      <tr>
        <th align="right">{$lang.consumer_price}：</th>
      	<td colspan="9" align="left"> 
        	{$sample.consumer_price|escape}
		</td>
 	  </tr>
 	  <!-- {/if} -->
      <!-- {if $user.role==USER_CLIENT or $user.role==USER_MERCHANDISER or $user.role==USER_MANAGER or $user.role==USER_CIVILIAN} -->
      <tr>
        <th align="right">{$lang.detail_thumb}：</th>
      	<td align="left"> 
	        <a href="{url app=sample&act=upload_thumb&sample_id=$sample.sample_id}">查看</a>
		</td>
		<th align="right">{$lang.recomm_color}：</th>
      	<td colspan="7" align="left"><a href="{url app=colorcard&act=recomm_view&sample_id=$sample.sample_id}">查看</a></td>
 	  </tr>
      <tr>
        <th rowspan="2" align="right">{$lang.customer_reviews}：</th>
      	<td colspan="9" align="left">
       
        <textarea style="width:95%; height:50px;" name="customer_reviews" <!-- {if $user.role!=USER_CLIENT} -->readonly<!-- {/if} -->>{$sample.customer_reviews|escape}</textarea>
 		</td>
 	</tr>
    <tr>
	 <td colspan="9" id="sample_consumer_reviews" align="left"> 
	        <!--{foreach from=$sample.customer_reviews_upload item=file}-->
			<span><a href="download.php?id={$file.file_id}" style="color:blue">{$file.file_name}</a>
	        &nbsp;&nbsp;<!--{if !$smarty.foreach.last}--></span><!--{/if}-->
			<!--{/foreach}--></td>
	 </tr>

      <tr>
		<th colspan="1" rowspan="2" align="right" >客户备注：</th>
        <td colspan="9" align="left" >
        <textarea name="consumer_remark" style="height:50px; width:95%;" <!-- {if $user.role!=USER_CLIENT} -->readonly<!-- {/if} -->>{$sample.consumer_remark}</textarea>
    </td>
       
      </tr>
      <tr> <td colspan="9" id="sample_consumer_remark" align="left">     
        <!--{foreach from=$sample.consumer_remark_upload item=file}-->
		<span><a href="download.php?id={$file.file_id}">{$file.file_name}</a>
		&nbsp;&nbsp;<!--{if !$smarty.foreach.last}--></span><!--{/if}-->
		<!--{/foreach}-->
        
		</td></tr>
		<!-- {/if} -->
      <tr>
        <th rowspan="2" align="right">{$lang.make_panel_reviews}：</th>
      	<td colspan="9" align="left">
			<div style="width: 99%;height: 100px;">{$sample.make_panel_reviews|escape}</div>
 </td></tr>
 
 <tr>
 <td colspan="9" id="sample_makepanel_filesize" align="left"> 
        <!--{foreach from=$sample.makepanel_files item=file}-->
		<a href="download.php?id={$file.file_id}" style="color:blue">{$file.file_name}</a>
        &nbsp;&nbsp;<!--{if !$smarty.foreach.last}--><!--{/if}-->
		<!--{/foreach}--></td>
 </tr>

      <tr>
             {if $user.is_factory neq 1}
		<th colspan="1" rowspan="2" align="right" >备注：</th>
        <td colspan="9"  align="left">
      		<textarea name="customer_reviews_text" {if $user.role neq USER_MERCHANDISER AND $user.role neq USER_CIVILIAN AND $user.role neq USER_MANAGER}readonly {/if} style="height:50px; width:95%;">{$sample.customer_reviews_text}</textarea>
    </td>
       
      </tr>
      <tr> <td colspan="9" id="sample_customer_filesize" align="left">     
		{if $user.role eq USER_MERCHANDISER || $user.role eq USER_CIVILIAN || $user.role eq USER_MANAGER}
		<input type="button" class="btn-3" value="{$lang.upload_enclosure}" onClick="upload_docs({$belongs_sample_customer_reviews}, {$sample.sample_id});" /><br />
       	{/if}
        <!--{foreach from=$sample.customer_reviews_files item=file}-->
		<a href="download.php?id={$file.file_id}" style="color:blue">{$file.file_name}</a>&nbsp;&nbsp;<!--{if !$smarty.foreach.last}--><!--{/if}-->
		<!--{/foreach}-->
        
		{/if}</td></tr>
      <tr>
        <th colspan="1" align="right" style="font-size:12px;">{$lang.fabric_info}：<br></th>
       <td colspan="9" style="margin:0; padding:0;">
       <table width="100%" class="fabric_info_table" cellpadding="0" cellspacing="0">
       <th width="15%" class="no_left_border">面料描述</th>
       <th width="28%">{$lang.fabric_shop_name}</th>
       <th width="10%">品名/货号</th>
       <th width="8%" >价格</th>
       <th width="8%" >幅宽</th>
       <th width="5%">色卡</th>
      <!--{foreach from=$fabric_info_list item=fabric_info name=fi}-->
       <tr class="fabric_info_list center">
       <td>
       <input name="fabric_info_id[]" type="hidden" value="{$fabric_info.fabric_info_id}" />
       <input name="description[]" item="description" type="hidden"  value="{$fabric_info.description|escape}" />{$fabric_info.description|escape}</td>
       <td>
       <input name="fabric_shop_name[]" item="fabric_shop_name" type="hidden"  value="{$fabric_info.fabric_shop_id}" />
{$fabric_info.fabric_shop_name}</td>    
       <td>
       <input name="item[]" item="item" type="hidden"  value="{$fabric_info.item}" />
{$fabric_info.item}
</td>
       <td>
       <input name="price[]" item="price" type="hidden"  value="{$fabric_info.price}" />
 {$fabric_info.price}</td>   
       <td>
        <input name="width[]" item="width" type="hidden"  value="{$fabric_info.width}" />
{$fabric_info.width}</td>
       <td>
       <a  item="picture_show" cid="{$fabric_info.cc_id}"  href="javascript:;">查看</a></td>

       </tr>
        <!--{foreachelse}-->
        <tr><td colspan="7" height="30">&nbsp;</td>
        </tr>
       <!--{/foreach}-->
  
       </table>
       
       </td>
      </tr>
      
     <tr height="45">
     <th colspan="1" align="right">尺寸文件：</th>
     <td colspan="9" style="margin:0; padding:0;">
     <table width="100%" class="table_no_border" border="0" cellpadding="0" cellspacing="0" style="padding:0; margin:0; height:45px;">
     <tr bgcolor="#F5F5F5">
        <td class="tab-align-l no_left_border" width="200" id="sample_filesize">
               <!--{foreach from=$sample.file_size item=file_size}-->
		<a href="download.php?id={$file_size.file_id}">{$file_size.file_name}</a>&nbsp;&nbsp;<!--{if !$smarty.foreach.last}--><!--{/if}-->
		<!--{/foreach}-->
        </td>
         <th width="82" align="right">{$lang.factory_price}：</th>
        <td width="80" class="tab-align-l">{if $sample.factory_price}{$sample.factory_price|escape}{$lang.rmb_yuan}{/if}</td>
        <th align="right" width="96" colspan="1">{$lang.quotation}：</th>
        <td width="130"  class="tab-align-l" id="factory_files">
        <!--{foreach from=$sample.factory_files item=file}-->
		<a target="_blank" href="download.php?id={$file.file_id}">{$file.file_name}</a>&nbsp;&nbsp;<!--{if !$smarty.foreach.last}--><!--{/if}-->
		<!--{/foreach}-->

        </td>
        
          <th colspan="1" width="120" align="right" class="no_right_border">预计交办日期：</th>
        <td class="tab-align-l" >
        {$sample.predict_assign_date|date:Y-m-d}

        </td>
	</tr>
        </table>
        </td>
      </tr>
     
      <tr style="display:none;" class="approve_no_desc_block"><th colspan="1" align="right">审批不通过理由：</th>
      <td colspan="9">
       <div style="display:none; width:200px; height:300px;" id="block" >
      <textarea style="width:100%; height:60px;" id="approve_no_desc"  name="approve_no_desc"></textarea>
      <textarea style="width:100%; height:60px;" id="return_factory_desc"  name="return_factory_desc"></textarea>
      </div>
      </td>
      </tr>
     <tr height="30">
        <th colspan="1" align="right">进度记录：</th>
        <td colspan="9" align="left">
       <table  width="100%"><tr><td id="record_list" width="80%">
        {foreach from=$pro_records_list item=rec_item}
       <p>{$rec_item.rec_time|date:m-d}&nbsp:&nbsp{$rec_item.rec_buff}&nbsp&nbsp({$rec_item.rec_name})</p>
       {/foreach}
       </td><td align="center">  
       {if $user.role eq USER_MERCHANDISER || $user.role eq USER_CIVILIAN}
              <input type="submit" class="btn-2" value="保存资料"><br />  
              {if $user.role eq USER_MERCHANDISER} 
              <input name="merchant_fabric" value="面料需求" type="button" class="btn-2" onclick="assign_merch_fabric()" /><br/>
              {/if}
       {/if}  
       {if $user.role eq USER_MANAGER}
		<input name="merchant_fabric" value="面料需求" type="button" class="btn-2" onclick="assign_merch_fabric()" />
		{/if}
        <input type="button"  class="btn-2" onClick="javascript:window.open('{$site_url}/index.php?app=sample&act=printsample&id={$smarty.get.id}');" value="打印样板"><br />

        <input type="button"  class="btn-2" onClick="history.back();"  value="返回"/>

        </td></tr></table>

        </td>
      </tr>
    </table>
	</form>
  </div>
</div>
<script language="javascript" type="text/javascript" src="{res file=js/tab_color.js}"></script>
</body>
{$async_sendmail}
</html>